<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of EmpleadoDB
 *
 * @author Admin
 */
class Consulta7DB extends CI_Model {

    var $title = '';
    var $content = '';
    var $date = '';

    function __construct() {
        // Call the Model constructor
        parent::__construct();
    }

    function Consulta7($arrData) {


        $query = $this->db
                ->select("cod_b,cod_s,COUNT('ci_pd') AS nci_pd")
                ->from("atrxj")                
                ->where("f_atr >=",$arrData['f_ini'])
                ->where("f_atr <=",$arrData['f_fin'])
                ->group_by(array("cod_b","cod_s"))
                ->get();
        return $query->result();  //                 
    }
    
    function Consulta7_1($arrData){
        
        
        /* $this->db->query('
                SELECT bancos.cod_b,bancos.deno,COUNT(*) AS num
                FROM atrxj JOIN bancos ON atrxj.cod_b=bancos.cod_b                
                WHERE f_atr >= $arrData["f_ini"] AND 
                      f_atr <= $arrData["f_ini"] 
                    GROUP BY cod_b; '); */
        
        $query2 = $this->db
                ->select("bancos.cod_b AS codb,bancos.deno AS denom,COUNT(*) AS num")
                ->from("atrxj")
                ->join('bancos', 'bancos.cod_b=atrxj.cod_b' )
                ->where("f_atr >=",$arrData['f_ini'])
                ->where("f_atr <=",$arrData['f_fin'])
                ->group_by(array("bancos.cod_b"))
                ->get();
        return $query2->result();           
    }
}    